//玩家类
module.exports = function(chair,channel) {
	//初始化信息
	this.uid = 0
	this.playerInfo = {}
	this.chair = chair
	this.channel = channel
	this.gold = 0
	this.isActive = false  			//激活状态
	this.isReady = false 			//准备状态
	this.isOnline = false  			//在线状态
	this.isRobot = false 			//机器人标识
	//初始化玩家数据
	this.init = function(uid,playerInfo) {
		this.uid = uid
		this.playerInfo = playerInfo
        this.playerInfo.goldPlayCount = parseInt(this.playerInfo.goldPlayCount)
		this.gold = parseInt(playerInfo.gold)
		this.isActive = true
		this.isReady = false
		this.isOnline = true
        if(this.uid <= 10000){
            this.isRobot = true
        }
	}
	//重置到初始状态
	this.reset = function() {
		this.uid = 0
		this.playerInfo = {}
		this.isActive = false
		this.isReady = false
		this.isOnline = false
	}
    //发送聊天消息
    this.say = function(msg) {
      var notify = {
        cmd : "sayMsg",
        uid : this.uid,
        chair : this.chair,
        msg : msg
      }
      this.channel.pushMessage('onMessage',notify)
    }
    //获取玩家数据
    this.getInfo = function() {
    	var info = {
    		chair : this.chair,
    		uid : this.uid,
    		playerInfo : this.playerInfo,
    		isActive : this.isActive,
    		isReady : this.isReady,
    		isOnline : this.isOnline,
    		gold : this.gold
    	}
    	return info
    }
    //获取简单数据
    this.getEasyInfo = function(argument) {
    	var info = {
    		uid : this.uid,
    		head : this.playerInfo.head,
    		nickname : this.playerInfo.nickname
    	}
    	return info
    }
}